<template>
  <div>
    <el-breadcrumb
      separator-class="el-icon-arrow-right"
      class="breadcrumb-base"
      style="line-height: 30px"
    >
      <el-breadcrumb-item :to="{ path: '/institution/info' }">
        <i class="el-icon-office-building"></i>
        机构信息
      </el-breadcrumb-item>
      <el-breadcrumb-item>编辑</el-breadcrumb-item>
    </el-breadcrumb>

    <div class="main-container">
      <el-form ref="institution" :model="institution" label-width="100px">
        <el-row class="line-text-title" type="flex" justify="middle">
          <span class="title-medium text-important">基础信息</span>
        </el-row>

        <el-row>
          <el-col :span="8">
            <el-form-item label="系统名称">
              <el-input
                v-model="institution.abbreviation"
                placeholder="请输入系统名称"
                class="input-form"
                size="mini"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="机构名称">
              <el-input
                v-model="institution.name"
                placeholder="请输入机构名称"
                class="input-form"
                size="mini"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="机构类型">
              <el-select
                v-model="institution.institutionType"
                placeholder="请选择机构类型"
                size="mini"
                class="picker-form"
              >
                <el-option
                  v-for="(item, index) in typeList"
                  :key="index"
                  :label="item.name"
                  :value="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="机构等级">
              <el-select
                v-model="institution.institutionLevel"
                placeholder="请选择机构等级"
                size="mini"
                class="picker-form"
              >
                <el-option
                  v-for="(item, index) in levelList"
                  :key="index"
                  :label="item.name"
                  :value="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="机构性质">
              <el-select
                v-model="institution.institutionKind"
                placeholder="请选择机构性质"
                size="mini"
                class="picker-form"
              >
                <el-option
                  v-for="(item, index) in kindList"
                  :key="index"
                  :label="item.name"
                  :value="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="经营性质">
              <el-select
                v-model="institution.businessNature"
                placeholder="请选择经营性质"
                size="mini"
                class="picker-form"
              >
                <el-option
                  v-for="(item, index) in businessList"
                  :key="index"
                  :label="item.name"
                  :value="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="所有制形式">
              <el-select
                v-model="institution.ownership"
                placeholder="请选择所有制形式"
                size="mini"
                class="picker-form"
              >
                <el-option
                  v-for="(item, index) in ownershipList"
                  :key="index"
                  :label="item.name"
                  :value="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="16">
            <el-form-item label="机构地址">
              <!--<el-select v-model="institution.area"-->
              <!--placeholder="请选择机构所在地市区"-->
              <!--size="mini"-->
              <!--class="picker-form">-->
              <!--<el-option-->
              <!--v-for="(item, index) in areaList"-->
              <!--:key="index"-->
              <!--:label="item.name"-->
              <!--:value="item.id">-->
              <!--</el-option>-->
              <!--</el-select>-->
              <el-cascader
                v-model="institution.area"
                placeholder="请选择机构所在地市区"
                size="mini"
                class="picker-form"
                :options="areaList"
                :props="{
                                    children: 'childrenList',
                                    value: 'id',
                                    label: 'name',
                                }"
              ></el-cascader>
              <el-input
                v-model="institution.address"
                placeholder="请输入机构地址"
                class="input-form"
                size="mini"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <div v-if="isPlatform">
          <!-- <el-row
                        class="line-text-title"
                        type="flex"
                        justify="middle"
                    >
                        <span class="title-medium text-important">扫描设置</span>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="扫描间隔时间">
                                <el-input
                                    v-model="institution.scanInterval"
                                    placeholder="请输入扫描间隔时间"
                                    style="vertical-align: unset"
                                    class="input-form"
                                    size="mini"
                                >
                                    <template slot="append">秒</template>
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="监控间隔时间">
                                <el-input
                                    v-model="institution.monitoringInterval"
                                    placeholder="请输入监控间隔时间"
                                    style="vertical-align: unset"
                                    class="input-form"
                                    size="mini"
                                >
                                    <template slot="append">秒</template>
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="扫描起始日期">
                                <el-date-picker
                                    v-model="institution.scanStartDate"
                                    value-format="timestamp"
                                    placeholder="选择日期"
                                    class="input-form"
                                    size="mini"
                                    type="date"
                                >
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="源文件目录">
                                <el-input
                                    v-model="institution.sourceFileAddr"
                                    placeholder="请输入源文件目录"
                                    class="input-form"
                                    size="mini"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="目标文件目录">
                                <el-input
                                    v-model="institution.targetFileAddr"
                                    placeholder="请输入目标文件目录"
                                    class="input-form"
                                    size="mini"
                                ></el-input>
                            </el-form-item>
                        </el-col>
          </el-row>-->
          <el-row class="line-text-title" type="flex" justify="middle">
            <span class="title-medium text-important">安全设置</span>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="会话失效时间">
                <el-input
                  v-model="institution.expireSeconds"
                  placeholder="请输入会话失效时间"
                  style="vertical-align: unset"
                  class="input-form"
                  size="mini"
                >
                  <template slot="append">分</template>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="启用强密码">
                <el-switch v-model="institution.passwordStrength" active-color="#13ce66"></el-switch>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row class="line-text-title" type="flex" justify="middle">
            <span class="title-medium text-important">诊断设置</span>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="启用任务认领">
                <el-radio-group
                  v-model="institution.isEnableTaskClaim"
                  size="mini"
                  class="radio-group"
                >
                  <el-radio
                    v-for="t in simpleRadioList"
                    :label="t.value"
                    :key="t.value"
                    size="mini"
                  >{{ t.name }}</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="启用诊断组">
                <el-radio-group
                  v-model="institution.isEnableSubgroup"
                  size="mini"
                  class="radio-group"
                >
                  <el-radio
                    v-for="t in simpleRadioList"
                    :label="t.value"
                    :key="t.value"
                    size="mini"
                  >{{ t.name }}</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <!-- <el-row>
                        <el-col :span="8">
                            <el-form-item label="必须初诊">
                                <el-radio-group
                                    v-model="specialSubgroup.needFirstVisit"
                                    size="mini"
                                    class="radio-group"
                                >
                                    <el-radio
                                        v-for="t in simpleRadioList"
                                        :label="t.value"
                                        :key="t.value"
                                        size="mini"
                                    >{{ t.name }}</el-radio>
                                </el-radio-group>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="越级提交">
                                <el-radio-group
                                    v-model="specialSubgroup.needSkipSubmit"
                                    size="mini"
                                    class="radio-group"
                                >
                                    <el-radio
                                        v-for="t in simpleRadioList"
                                        :label="t.value"
                                        :key="t.value"
                                        size="mini"
                                    >{{ t.name }}</el-radio>
                                </el-radio-group>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="必须终审">
                                <el-radio-group
                                    v-model="specialSubgroup.needFinalVerify"
                                    size="mini"
                                    class="radio-group"
                                >
                                    <el-radio
                                        v-for="t in simpleRadioList"
                                        :label="t.value"
                                        :key="t.value"
                                        size="mini"
                                    >{{ t.name }}</el-radio>
                                </el-radio-group>
                            </el-form-item>
                        </el-col>
          </el-row>-->
          <!-- <el-row
                        v-show="institution.isEnableSubgroup"
                        class="line-text-title"
                        type="flex"
                        justify="middle"
                    >
                        <span class="title-medium text-important">诊断组设置</span>
                    </el-row>
                    <el-row v-show="institution.isEnableSubgroup">
                        <el-form-item label="必须初诊">
                            <el-checkbox
                                :indeterminate="
                                    needFirstVisitMultipleIndeterminate
                                "
                                v-model="needFirstVisitMultipleCheckedAll"
                                @change="needFirstVisitMultipleCheckAll"
                                style="display: inline"
                            >
                                全选
                            </el-checkbox>
                            <el-checkbox-group
                                v-model="needFirstVisitMultiple"
                                @change="needFirstVisitMultipleChange"
                                style="display: inline"
                            >
                                <el-checkbox
                                    v-for="t in subgroupList"
                                    :label="t.index"
                                    :key="t.id"
                                    size="mini"
                                >{{ t.name }}</el-checkbox>
                            </el-checkbox-group>
                        </el-form-item>
                    </el-row>
                    <el-row v-show="institution.isEnableSubgroup">
                        <el-form-item label="越级提交">
                            <el-checkbox
                                :indeterminate="
                                    needSkipSubmitMultipleIndeterminate
                                "
                                v-model="needSkipSubmitMultipleCheckedAll"
                                @change="needSkipSubmitMultipleCheckAll"
                                style="display: inline"
                            >
                                全选
                            </el-checkbox>
                            <el-checkbox-group
                                v-model="needSkipSubmitMultiple"
                                @change="needSkipSubmitMultipleChange"
                                style="display: inline"
                            >
                                <el-checkbox
                                    v-for="t in subgroupList"
                                    :label="t.index"
                                    :key="t.id"
                                    size="mini"
                                >{{ t.name }}</el-checkbox>
                            </el-checkbox-group>
                        </el-form-item>
                    </el-row>
                    <el-row v-show="institution.isEnableSubgroup">
                        <el-form-item label="必须终审">
                            <el-checkbox
                                :indeterminate="
                                    needFinalVerifyMultipleIndeterminate
                                "
                                v-model="needFinalVerifyMultipleCheckedAll"
                                @change="needFinalVerifyMultipleCheckAll"
                                style="display: inline"
                            >
                                全选
                            </el-checkbox>
                            <el-checkbox-group
                                v-model="needFinalVerifyMultiple"
                                @change="needFinalVerifyMultipleChange"
                                style="display: inline"
                            >
                                <el-checkbox
                                    v-for="t in subgroupList"
                                    :label="t.index"
                                    :key="t.id"
                                    size="mini"
                                >{{ t.name }}</el-checkbox>
                            </el-checkbox-group>
                        </el-form-item>
          </el-row>-->
          <el-row class="line-text-title" type="flex" justify="middle">
            <span class="title-medium text-important">其他信息</span>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="诊疗科目">
                <el-input
                  type="textarea"
                  :rows="3"
                  style="width: 100%"
                  placeholder="请输入内容"
                  v-model="institution.diagnosisSubject"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="机构介绍">
                <el-input
                  type="textarea"
                  :rows="3"
                  style="width: 100%"
                  placeholder="请输入内容"
                  v-model="institution.introduce"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row style="margin-top: 15px">
            <el-col :span="8">
              <el-form-item label="机构执业证照">
                <el-upload
                  :action="imageServiceUploadURL"
                  :on-success="practiceLicenseUploadSuccess"
                  :show-file-list="false"
                  :drag="true"
                >
                  <img
                    v-if="institution.licenseUrl"
                    :src="practiceLicensePreview"
                    class="avatar-uploader-img"
                    alt
                  />
                  <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                  <div slot="tip" class="el-upload__tip" style="margin-top: -15px">只能上传jpg/png/bmp文件</div>
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="执业资格证照">
                <el-upload
                  :action="imageServiceUploadURL"
                  :on-success="
                                        qualificationLicenseUploadSuccess
                                    "
                  :show-file-list="false"
                  :drag="true"
                >
                  <img
                    v-if="institution.qualificationUrl"
                    :src="qualificationLicensePreview"
                    class="avatar-uploader-img"
                    alt
                  />
                  <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                  <div slot="tip" class="el-upload__tip" style="margin-top: -15px">只能上传jpg/png/bmp文件</div>
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="机构Logo">
                <el-upload
                  :action="imageServiceUploadURL"
                  :on-success="logoUploadSuccess"
                  :show-file-list="false"
                  :drag="true"
                >
                  <img
                    v-if="institution.logoUrl"
                    :src="logoPreview"
                    class="avatar-uploader-img"
                    alt
                  />
                  <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                  <div slot="tip" class="el-upload__tip" style="margin-top: -15px">只能上传jpg/png/bmp文件</div>
                </el-upload>
              </el-form-item>
            </el-col>
          </el-row>
        </div>
      </el-form>
      <el-row type="flex" justify="center">
        <el-button @click="formCommit" type="primary" size="mini" style="margin: 0 10px">提交</el-button>
        <el-button @click="jumpBack" size="mini" style="margin: 0 10px">返回</el-button>
      </el-row>
    </div>
  </div>
</template>

<script>
import _ from 'lodash';

export default {
  name: 'InstitutionInfoEdit',
  data() {
    return {
      // 图片服务器地址
      imageServiceURL: process.env.ImageServiceURL,
      // 图片服务器上传地址
      imageServiceUploadURL: `${process.env.ImageServiceURL}/upload`,
      isPlatform: this.$store.state.institution.isPlatform,
      // 表单
      institution: {
        id: 0,
        isPlatform: this.$store.state.institution.isPlatform,
        // 基础信息
        name: '',
        area: [],
        address: '',

        abbreviation: '',
        institutionType: '',
        institutionLevel: '',
        ownership: '',

        institutionKind: '',
        businessNature: '',
        // 扫描设置
        scanInterval: '',
        monitoringInterval: '',
        scanStartDate: '',
        //安全设置
        expireSeconds: 10,
        passwordStrength: true,

        sourceFileAddr: '',
        targetFileAddr: '',
        // 诊断设置
        isEnableTaskClaim: 0,
        isEnableSubgroup: 0,
        // TODO 会诊设置
        canConsultation: false,
        //   isProvideService: false,
        //   canFinalVerify: false,
        // 其他信息
        diagnosisSubject: '',
        introduce: '',

        // 机构执业证照
        licenseUrl: '',
        // 机构资格证照
        qualificationUrl: '',
        // 机构Logo照
        logoUrl: '',
        provinceId: 0,
        cityId: 0,
        countyId: 0
      },
      // 省市区
      areaList: [],
      // 机构类型
      typeList: [],
      // 机构等级
      levelList: [],
      // 所有制形式
      ownershipList: [],
      // 机构性质
      kindList: [],
      // 经营性质
      businessList: [],
      // 调度方式
      dispatchTypeList: [],
      // 特殊诊断组设置
      specialSubgroup: {
        id: 0,
        needFirstVisit: 0,
        needSkipSubmit: 0,
        needFinalVerify: 0
      },
      // 诊断组列表
      subgroupList: [
        {
          id: 0,
          needFirstVisit: 0,
          needSkipSubmit: 0,
          needFinalVerify: 0
        }
      ],
      needFirstVisitMultiple: [],
      needFirstVisitMultipleCheckedAll: false,
      needSkipSubmitMultiple: [],
      needSkipSubmitMultipleCheckedAll: false,
      needFinalVerifyMultiple: [],
      needFinalVerifyMultipleCheckedAll: false,
      // 是否启用诊断
      isEnableSubgroupList: [
        { name: '否', label: 0 },
        { name: '是', label: 1 }
      ],
      // 是否启用认领
      simpleRadioList: [
        { value: 0, name: '否' },
        { value: 1, name: '是' }
      ],

      dictRequestMap: [
        {
          dict: 'hospitaltype',
          list: 'typeList'
        },
        {
          dict: 'HospitalLevel',
          list: 'levelList'
        },
        {
          dict: 'OwnerShip',
          list: 'ownershipList'
        },
        {
          dict: 'businessnature',
          list: 'businessList'
        },
        {
          dict: 'HospitalKind',
          list: 'kindList'
        },
        {
          dict: 'dispatchType',
          list: 'dispatchTypeList'
        }
      ]
    };
  },
  async mounted() {
    // 请求机构详细信息
    const { state } = this.$store;
    let res;
    let result;
    res = await this.$axios({
      // 详见 axios 请求配置项
      method: 'GET',
      url: `/PROXY-Remote/institutions/${state.institution.id}`
    });
    console.log('res', res);
    if (res && res.data.code === 200) {
      Object.keys(this.institution).forEach(key => {
        this.institution[key] = res.data.data[key];
      });
      this.institution.area = [
        this.institution.provinceId,
        this.institution.cityId,
        this.institution.countyId
      ];
      this.institution.passwordStrength =
        res.data.data.passwordStrength == 'true' ? true : false;
      this.institution.expireSeconds = parseInt(
        Number(this.institution.expireSeconds) / 60
      );
    }

    // 请求字典数据
    await this.dictRequestMap.forEach(map => {
      this.$axios({
        method: 'GET',
        url: '/PROXY-Remote/dicts/list',
        params: {
          code: map.dict,
          page: 0,
          size: 99
        }
      }).then(response => {
        if (response && response.data.code === 200) {
          this[map.list] = _.clone(response.data.data);
        }
      });
    });

    // 请求特殊诊断组数据
    // res = await this.$axios({
    //     method: 'GET',
    //     url: '/PROXY-Remote/subgroups/special',
    // });
    // if (res && res.data.code === 200) {
    //     result = res.data.data;
    //     this.specialSubgroup = {
    //         id: result.id,
    //         needFirstVisit: result.needFirstVisit,
    //         needSkipSubmit: result.needSkipSubmit,
    //         needFinalVerify: result.needFinalVerify,
    //     };
    // }

    // 请求所有诊断组数据
    // res = await this.$axios({
    //     method: 'GET',
    //     url: '/PROXY-Remote/subgroups',
    //     params: {
    //         page: 0,
    //         size: 999,
    //     },
    // });
    // if (res && res.data.code === 200) {
    //     result = res.data.data;
    //     this.subgroupList = [];
    //     result.forEach((t, index) => {
    //         this.subgroupList.push({
    //             index,
    //             id: t.id,
    //             name: t.name,
    //             needFirstVisit: t.needFirstVisit,
    //             needSkipSubmit: t.needSkipSubmit,
    //             needFinalVerify: t.needFinalVerify,
    //         });

    //         if (t.needFirstVisit) {
    //             this.needFirstVisitMultiple.push(index);
    //             this.needFirstVisitMultipleChange(
    //                 this.needFirstVisitMultiple
    //             );
    //         }
    //         if (t.needSkipSubmit) {
    //             this.needSkipSubmitMultiple.push(index);
    //             this.needSkipSubmitMultipleChange(
    //                 this.needSkipSubmitMultiple
    //             );
    //         }
    //         if (t.needFinalVerify) {
    //             this.needFinalVerifyMultiple.push(index);
    //             this.needFinalVerifyMultipleChange(
    //                 this.needFinalVerifyMultiple
    //             );
    //         }
    //     });
    // }

    // 请求所有省市区数据
    res = await this.$axios({
      method: 'GET',
      url: '/PROXY-Remote/provinces'
    });
    if (res && res.data.code === 200) {
      result = res.data.data;
      this.areaList = [];
      result.forEach(t => {
        this.areaList.push(t);
      });
    }
  },
  computed: {
    needFirstVisitMultipleIndeterminate() {
      const len = this.needFirstVisitMultiple.length;
      return len > 0 && len < this.subgroupList.length;
    },
    needSkipSubmitMultipleIndeterminate() {
      const len = this.needSkipSubmitMultiple.length;
      return len > 0 && len < this.subgroupList.length;
    },
    needFinalVerifyMultipleIndeterminate() {
      const len = this.needFinalVerifyMultiple.length;
      return len > 0 && len < this.subgroupList.length;
    },
    practiceLicensePreview() {
      return this.imageServiceURL + this.institution.licenseUrl;
    },
    qualificationLicensePreview() {
      return this.imageServiceURL + this.institution.qualificationUrl;
    },
    logoPreview() {
      return this.imageServiceURL + this.institution.logoUrl;
    }
  },
  methods: {
    // @blur="prepareSessionInvalidation"
    prepareSessionInvalidation() {
      if (Number(this.institution.expireSeconds) < 10) {
        this.$message.info('会话失效时间最好不要低于10分钟');
      } else if (Number(this.institution.expireSeconds) > 720) {
        this.$message.info('会话失效时间最好不要大于720分钟');
        this.institution.expireSeconds = 720;
      }
    },
    formCommit() {
      // 提交
      // 机构数据保存
      let flagInfo = false;
      let flagSubgroup = false;
      if (this.institution.area.length === 3) {
        const provinceId = this.institution.area[0];
        this.institution.provinceId = provinceId;
        const cityId = this.institution.area[1];
        this.institution.cityId = cityId;
        const countyId = this.institution.area[2];
        this.institution.countyId = countyId;
      } else if (this.institution.area.length === 2) {
        const provinceId = this.institution.area[0];
        this.institution.provinceId = provinceId;
        const cityId = this.institution.area[1];
        this.institution.cityId = cityId;
      } else if (this.institution.area.length === 1) {
        const provinceId = this.institution.area[0];
        this.institution.provinceId = provinceId;
      }
      this.institution.expireSeconds =
        Number(this.institution.expireSeconds) * 60;
      this.$axios({
        method: 'PUT',
        url: `/PROXY-Remote/institutions/${this.institution.id}`,
        data: this.institution
      })
        .then(res => {
          if (res && res.data.code === 200) {
            this.institution.expireSeconds =
              Number(this.institution.expireSeconds) / 60;
            flagInfo = true;
            // 更新数据到 vuex
            const institution = {
              id: this.institution.id,
              isPlatform: this.institution.isPlatform,
              name: this.institution.name,
              isEnableTaskClaim: this.institution.isEnableTaskClaim
            };
            this.$store.commit('setInstitution', institution);
            this.$message.success('保存成功');
          } else {
            this.$message.warning('机构信息保存失败');
          }
        })
        .catch(error => {
          this.$message.warning(error.message);
        });

      // 诊断组数据保存
      // this.needFirstVisitMultiple.forEach((index) => {
      //     this.subgroupList[index].needFirstVisit = 1;
      // });
      // this.needSkipSubmitMultiple.forEach((index) => {
      //     this.subgroupList[index].needSkipSubmit = 1;
      // });
      // this.needFinalVerifyMultiple.forEach((index) => {
      //     this.subgroupList[index].needFinalVerify = 1;
      // });
      // 保存请求
      // 对诊断的保存请求必须存在，否则通用诊断诊断设置无法更新
      // const subgroups = _.clone(this.subgroupList);
      // subgroups.push(this.specialSubgroup);
      // this.$axios({
      //     method: 'POST',
      //     url: '/PROXY-Remote/subgroups/bulk-update',
      //     headers: {
      //         'Content-Type': 'application/json',
      //     },
      //     data: subgroups,
      // }).then((res) => {
      //     if (res && res.data.code === 200) {
      //         flagSubgroup = true;
      //     } else if (this.institution.isEnableSubgroup) {
      //         this.$message.warning('诊断组信息保存失败');
      //     } else {
      //         flagSubgroup = true;
      //     }

      //     if (flagInfo && flagSubgroup) {
      //         this.$message.success('保存成功');
      //     }
      // });
    },
    jumpBack() {
      // 返回
      this.$router.go(-1);
    },

    needFirstVisitMultipleCheckAll(val) {
      this.needFirstVisitMultiple = [];

      if (val) {
        this.subgroupList.forEach(t => {
          this.needFirstVisitMultiple.push(t.index);
        });
      }
    },
    needFirstVisitMultipleChange(value) {
      this.needFirstVisitMultipleCheckedAll =
        value.length === this.subgroupList.length;
    },
    needSkipSubmitMultipleCheckAll(val) {
      this.needSkipSubmitMultiple = [];

      if (val) {
        this.subgroupList.forEach(t => {
          this.needSkipSubmitMultiple.push(t.index);
        });
      }
    },
    needSkipSubmitMultipleChange(value) {
      this.needSkipSubmitMultipleCheckedAll =
        value.length === this.subgroupList.length;
    },
    needFinalVerifyMultipleCheckAll(val) {
      this.needFinalVerifyMultiple = [];

      if (val) {
        this.subgroupList.forEach(t => {
          this.needFinalVerifyMultiple.push(t.index);
        });
      }
    },
    needFinalVerifyMultipleChange(value) {
      this.needFinalVerifyMultipleCheckedAll =
        value.length === this.subgroupList.length;
    },
    // 图片上传
    practiceLicenseUploadSuccess(res) {
      if (res.status === 'success') {
        this.institution.licenseUrl = res.url.slice(res.url.indexOf('_') - 1);
      }
    },
    qualificationLicenseUploadSuccess(res) {
      if (res.status === 'success') {
        this.institution.qualificationUrl = res.url.slice(
          res.url.indexOf('_') - 1
        );
      }
    },
    logoUploadSuccess(res) {
      if (res.status === 'success') {
        this.institution.logoUrl = res.url.slice(res.url.indexOf('_') - 1);
      }
    }
  }
};
</script>

<style scoped>
</style>
